/**
 *
 *  裁判模型
 *
 *  任务1
 *  获取所有裁判
 */

module.exports = class extends think.Model
{

    get pk()
    {
        return 'PK_JudgerGuid';
    }

    get relation()
    {
        return {
            competitionstepstojudger: {
                type: think.Model.HAS_MANY,
                key: 'PK_JudgerGuid',
                fKey: 'FK_JudgerGuid'
            }
        }
    }

    async getAllJudger()
    {
        let field = 'PK_JudgerGuid as guid,Name';
        return await this.field(field).where({IsDelete: '未删除'}).select();
    }

    //获取裁判的所有步骤
    async getStepsByJrguid(jrguid)
    {
        let judgerDetails = await this.find(jrguid);
        let steps = [];
        judgerDetails.competitionstepstojudger.forEach(function (val)
        {
            steps.push(val);
            // steps.push(val.FK_CompetitionStepsGuid); //old
        })
        return steps;
    }


}